//
//  NSFileManager+WMUtils.m
//  WholeMusic
//
//  Created by quanxiong on 2018/2/25.
//  Copyright © 2018年 quanxiong. All rights reserved.
//

#import "NSFileManager+WMUtils.h"

@implementation NSFileManager (WMUtils)

// 判断目录是否存在，不存在则创建
+ (BOOL)createDirectorIfNeed:(NSString *)director {
    NSFileManager *fileManager = [NSFileManager defaultManager];
    BOOL isDir = FALSE;
    BOOL isDirExist = [fileManager fileExistsAtPath:director isDirectory:&isDir];
    
    if(!(isDirExist && isDir)) {
        NSError *error;
        BOOL success = [fileManager createDirectoryAtPath:director
                              withIntermediateDirectories:YES
                                               attributes:nil
                                                    error:&error];
        if (!success) {
            NSLog(@"%@", error);
        }
        return success;
    }
    return YES;
}

@end
